@extends('layouts.admin')
@section('content')
    <style>
        .table tbody tr td{
            text-align:center;
        }
        .dataTables_filter{
            margin-left:20px;
        }
        form input{
            height:22px;
            text-align: center;
            line-height:20px;
            font-size:15px;
        }
    </style>

    <div id="content-header">
        <h1>Tables</h1>
        <div class="btn-group">
            <a class="btn btn-large tip-bottom" title="Manage Files"><i class="icon-file"></i></a>
            <a class="btn btn-large tip-bottom" title="Manage Users"><i class="icon-user"></i></a>
            <a class="btn btn-large tip-bottom" title="Manage Comments"><i class="icon-comment"></i><span class="label label-important">5</span></a>
            <a class="btn btn-large tip-bottom" title="Manage Orders"><i class="icon-shopping-cart"></i></a>
        </div>
    </div>
    <div id="breadcrumb">
        <a href="#" title="Go to Home" class="tip-bottom"><i class="icon-home"></i> Home</a>
        <a href="#" class="current">Tables</a>
    </div>
    <div class="dataTables_filter" id="DataTables_Table_0_filter">
        <form action="{{url('admin/specialdata')}}" method="get" enctype="multipart/form-data">
            {{csrf_field()}}
            <input type="text" name="username"  placeholder="用户名">&nbsp;&nbsp;&nbsp;
            <input type="text" name="tag"  placeholder="标签" >&nbsp;
            <input type="submit"value="搜索">
        </form>
    </div>
    <div class="container-fluid">
        <div class="row-fluid">
            <div class="span12">
                <div class="widget-box">
                    <div class="widget-title">
								<span class="icon">
									<i class="icon-th"></i>
								</span>
                        <h5>专辑列表</h5>
                    </div>
                    <div class="widget-content nopadding">
                        <table class="table table-bordered table-striped">
                            <thead>
                            <tr>
                                <th>ID</th>
                                <th>用户名</th>
                                <th>专辑名</th>
                                <th>图片</th>
                                <th>标签</th>
                                <th>专辑描述</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody id="tbody">
                            {{--在后台遍历数据--}}
                            @foreach($data as $d)
                                <tr>
                                    <td style="text-align:center;line-height:50px">{{$d->id}}</td>
                                    <td style="text-align:center;line-height:50px">{{$d->username}}</td>
                                    <td style="text-align:center;line-height:50px">{{$d->name}}</td>
                                    <td style="text-align:center;line-height:50px"><img src=" {{asset('public/').'/'.$d->pic}}" style="width:40px;height:40px;"></td>
                                    <td style="text-align:center;line-height:50px">{{$d->tag}}</td>
                                    <td style="text-align:center;line-height:50px">{{$d->desc}}</td>
                                    <td style="text-align:center;line-height:50px">
                                        @if($d->ban==1)
                                          <button class="btn btn-primary" id="btn{{$d->id}}" onclick="changeban(this,{{$d->id}})">
                                              允许
                                          </button>
                                            @else
                                            <button class="btn btn-primary" style="background:red;"id="btn{{$d->id}}" onclick="changeban(this,{{$d->id}})">
                                               禁止
                                            </button>
                                        @endif

                                    </td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                        <div class="dataTables_paginate">
                            {{$data->links()}}
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="row-fluid">
            <div id="footer" class="span12">
                2012 &copy; Unicorn Admin. Brought to you by <a href="https://wrapbootstrap.com/user/diablo9983">diablo9983</a>
            </div>
        </div>
    </div>
    <script>
        function changeban(obj,id){
            $.post("{{url('admin/changeBan')}}",{'_token':'{{csrf_token()}}','id':id},function(data){
                if(data.status==0){
                    layer.alert(data.msg, {icon: 1});
                    if ($('#btn'+id).html()=='允许') {
                        $('#btn'+id).html('禁止');
                        $('#btn'+id).css('background','red');

                    }else{
                        $('#btn'+id).html('允许');
                        $('#btn'+id).css('background','#428BCA');
                    }
                }else{
                    layer.msg(data.msg, {icon: 5});
                }
            });
        }
    </script>
@endsection





